package com.jetgege.bluetoothdemo;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jetgege on 2017/3/6.
 */

public class BlueListAdapter extends BaseAdapter {

    List<BluetoothDevice> devices;



    public BlueListAdapter(List<BluetoothDevice> devices)
    {
        this.devices=devices;
    }

    @Override
    public int getCount() {
        return devices.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.blue_list_item,parent,false);
        TextView tv_BlueName=(TextView)view.findViewById(R.id.tv_BlueName);
        TextView tv_BlueAddress=(TextView)view.findViewById(R.id.tv_BlueAddress);
        tv_BlueName.setText(devices.get(position).getName());
        tv_BlueAddress.setText(devices.get(position).getAddress());
        return view;
    }
}
